//暂时不适用
/**
 * 定义webSocket的各个阶段的函数
 * @param {String} vid 
 * @param {Function} onOpen 
 * @param {Function} onClose 
 * @param {Function} onError 
 * @param {Function} onMessage 
 * @returns 
 */
export function initWebSocket(vid, onOpen = () => {}, onClose = (e) => {}, onError = (e) => {}, onMessage = (event) => {}) {

  let socket = null;

  let websocketUrl = process.env.VUE_APP_WS_API;

  if('WebSocket' in window && websocketUrl){
    socket = new WebSocket(`${websocketUrl}/${vid}`);
    socket.onopen = onOpen;
    socket.onmessage = onMessage;
    socket.onclose = onClose;
    socket.onclose = onClose;
  }

  return socket;
}
